// $ANTLR 3.4 C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g 2013-02-25 17:56:00

  package com.pl;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

import org.antlr.runtime.tree.*;


@SuppressWarnings({"all", "warnings", "unchecked"})
public class ExpParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "BLANCO", "DIGITO", "DIV", "MULT", "NUMERO", "PAR_AB", "PAR_CER", "RESTA", "SEPARADOR", "SUMA", "LISTA_INST", "PARENTESIS"
    };

    public static final int EOF=-1;
    public static final int BLANCO=4;
    public static final int DIGITO=5;
    public static final int DIV=6;
    public static final int MULT=7;
    public static final int NUMERO=8;
    public static final int PAR_AB=9;
    public static final int PAR_CER=10;
    public static final int RESTA=11;
    public static final int SEPARADOR=12;
    public static final int SUMA=13;
    public static final int LISTA_INST=14;
    public static final int PARENTESIS=15;

    // delegates
    public Parser[] getDelegates() {
        return new Parser[] {};
    }

    // delegators


    public ExpParser(TokenStream input) {
        this(input, new RecognizerSharedState());
    }
    public ExpParser(TokenStream input, RecognizerSharedState state) {
        super(input, state);
    }

protected TreeAdaptor adaptor = new CommonTreeAdaptor();

public void setTreeAdaptor(TreeAdaptor adaptor) {
    this.adaptor = adaptor;
}
public TreeAdaptor getTreeAdaptor() {
    return adaptor;
}
    public String[] getTokenNames() { return ExpParser.tokenNames; }
    public String getGrammarFileName() { return "C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g"; }


    public static class instrucciones_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "instrucciones"
    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:19:1: instrucciones : ( expresion SEPARADOR )* EOF -> ^( LISTA_INST ( expresion )+ ) ;
    public final ExpParser.instrucciones_return instrucciones() throws RecognitionException {
        ExpParser.instrucciones_return retval = new ExpParser.instrucciones_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token SEPARADOR2=null;
        Token EOF3=null;
        ExpParser.expresion_return expresion1 =null;


        Object SEPARADOR2_tree=null;
        Object EOF3_tree=null;
        RewriteRuleTokenStream stream_EOF=new RewriteRuleTokenStream(adaptor,"token EOF");
        RewriteRuleTokenStream stream_SEPARADOR=new RewriteRuleTokenStream(adaptor,"token SEPARADOR");
        RewriteRuleSubtreeStream stream_expresion=new RewriteRuleSubtreeStream(adaptor,"rule expresion");
        try {
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:19:15: ( ( expresion SEPARADOR )* EOF -> ^( LISTA_INST ( expresion )+ ) )
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:19:17: ( expresion SEPARADOR )* EOF
            {
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:19:17: ( expresion SEPARADOR )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==NUMERO||LA1_0==PARENTESIS) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:19:18: expresion SEPARADOR
            	    {
            	    pushFollow(FOLLOW_expresion_in_instrucciones62);
            	    expresion1=expresion();

            	    state._fsp--;

            	    stream_expresion.add(expresion1.getTree());

            	    SEPARADOR2=(Token)match(input,SEPARADOR,FOLLOW_SEPARADOR_in_instrucciones64);  
            	    stream_SEPARADOR.add(SEPARADOR2);


            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);


            EOF3=(Token)match(input,EOF,FOLLOW_EOF_in_instrucciones68);  
            stream_EOF.add(EOF3);


            // AST REWRITE
            // elements: expresion
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 21:16: -> ^( LISTA_INST ( expresion )+ )
            {
                // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:21:19: ^( LISTA_INST ( expresion )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(
                (Object)adaptor.create(LISTA_INST, "LISTA_INST")
                , root_1);

                if ( !(stream_expresion.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_expresion.hasNext() ) {
                    adaptor.addChild(root_1, stream_expresion.nextTree());

                }
                stream_expresion.reset();

                adaptor.addChild(root_0, root_1);
                }

            }


            retval.tree = root_0;

            }

            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "instrucciones"


    public static class expresion_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "expresion"
    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:1: expresion : exp_mult ( ( SUMA ^| RESTA ^) exp_mult )* ;
    public final ExpParser.expresion_return expresion() throws RecognitionException {
        ExpParser.expresion_return retval = new ExpParser.expresion_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token SUMA5=null;
        Token RESTA6=null;
        ExpParser.exp_mult_return exp_mult4 =null;

        ExpParser.exp_mult_return exp_mult7 =null;


        Object SUMA5_tree=null;
        Object RESTA6_tree=null;

        try {
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:11: ( exp_mult ( ( SUMA ^| RESTA ^) exp_mult )* )
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:13: exp_mult ( ( SUMA ^| RESTA ^) exp_mult )*
            {
            root_0 = (Object)adaptor.nil();


            pushFollow(FOLLOW_exp_mult_in_expresion134);
            exp_mult4=exp_mult();

            state._fsp--;

            adaptor.addChild(root_0, exp_mult4.getTree());

            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:22: ( ( SUMA ^| RESTA ^) exp_mult )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==RESTA||LA3_0==SUMA) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:23: ( SUMA ^| RESTA ^) exp_mult
            	    {
            	    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:23: ( SUMA ^| RESTA ^)
            	    int alt2=2;
            	    int LA2_0 = input.LA(1);

            	    if ( (LA2_0==SUMA) ) {
            	        alt2=1;
            	    }
            	    else if ( (LA2_0==RESTA) ) {
            	        alt2=2;
            	    }
            	    else {
            	        NoViableAltException nvae =
            	            new NoViableAltException("", 2, 0, input);

            	        throw nvae;

            	    }
            	    switch (alt2) {
            	        case 1 :
            	            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:24: SUMA ^
            	            {
            	            SUMA5=(Token)match(input,SUMA,FOLLOW_SUMA_in_expresion138); 
            	            SUMA5_tree = 
            	            (Object)adaptor.create(SUMA5)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(SUMA5_tree, root_0);


            	            }
            	            break;
            	        case 2 :
            	            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:24:30: RESTA ^
            	            {
            	            RESTA6=(Token)match(input,RESTA,FOLLOW_RESTA_in_expresion141); 
            	            RESTA6_tree = 
            	            (Object)adaptor.create(RESTA6)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(RESTA6_tree, root_0);


            	            }
            	            break;

            	    }


            	    pushFollow(FOLLOW_exp_mult_in_expresion145);
            	    exp_mult7=exp_mult();

            	    state._fsp--;

            	    adaptor.addChild(root_0, exp_mult7.getTree());

            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "expresion"


    public static class exp_mult_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "exp_mult"
    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:1: exp_mult : exp_base ( ( MULT ^| DIV ^) exp_base )* ;
    public final ExpParser.exp_mult_return exp_mult() throws RecognitionException {
        ExpParser.exp_mult_return retval = new ExpParser.exp_mult_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token MULT9=null;
        Token DIV10=null;
        ExpParser.exp_base_return exp_base8 =null;

        ExpParser.exp_base_return exp_base11 =null;


        Object MULT9_tree=null;
        Object DIV10_tree=null;

        try {
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:10: ( exp_base ( ( MULT ^| DIV ^) exp_base )* )
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:12: exp_base ( ( MULT ^| DIV ^) exp_base )*
            {
            root_0 = (Object)adaptor.nil();


            pushFollow(FOLLOW_exp_base_in_exp_mult155);
            exp_base8=exp_base();

            state._fsp--;

            adaptor.addChild(root_0, exp_base8.getTree());

            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:21: ( ( MULT ^| DIV ^) exp_base )*
            loop5:
            do {
                int alt5=2;
                int LA5_0 = input.LA(1);

                if ( ((LA5_0 >= DIV && LA5_0 <= MULT)) ) {
                    alt5=1;
                }


                switch (alt5) {
            	case 1 :
            	    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:22: ( MULT ^| DIV ^) exp_base
            	    {
            	    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:22: ( MULT ^| DIV ^)
            	    int alt4=2;
            	    int LA4_0 = input.LA(1);

            	    if ( (LA4_0==MULT) ) {
            	        alt4=1;
            	    }
            	    else if ( (LA4_0==DIV) ) {
            	        alt4=2;
            	    }
            	    else {
            	        NoViableAltException nvae =
            	            new NoViableAltException("", 4, 0, input);

            	        throw nvae;

            	    }
            	    switch (alt4) {
            	        case 1 :
            	            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:23: MULT ^
            	            {
            	            MULT9=(Token)match(input,MULT,FOLLOW_MULT_in_exp_mult159); 
            	            MULT9_tree = 
            	            (Object)adaptor.create(MULT9)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(MULT9_tree, root_0);


            	            }
            	            break;
            	        case 2 :
            	            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:26:29: DIV ^
            	            {
            	            DIV10=(Token)match(input,DIV,FOLLOW_DIV_in_exp_mult162); 
            	            DIV10_tree = 
            	            (Object)adaptor.create(DIV10)
            	            ;
            	            root_0 = (Object)adaptor.becomeRoot(DIV10_tree, root_0);


            	            }
            	            break;

            	    }


            	    pushFollow(FOLLOW_exp_base_in_exp_mult166);
            	    exp_base11=exp_base();

            	    state._fsp--;

            	    adaptor.addChild(root_0, exp_base11.getTree());

            	    }
            	    break;

            	default :
            	    break loop5;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "exp_mult"


    public static class exp_base_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };


    // $ANTLR start "exp_base"
    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:28:1: exp_base : ( NUMERO | PARENTESIS expresion PARENTESIS );
    public final ExpParser.exp_base_return exp_base() throws RecognitionException {
        ExpParser.exp_base_return retval = new ExpParser.exp_base_return();
        retval.start = input.LT(1);


        Object root_0 = null;

        Token NUMERO12=null;
        Token PARENTESIS13=null;
        Token PARENTESIS15=null;
        ExpParser.expresion_return expresion14 =null;


        Object NUMERO12_tree=null;
        Object PARENTESIS13_tree=null;
        Object PARENTESIS15_tree=null;

        try {
            // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:28:10: ( NUMERO | PARENTESIS expresion PARENTESIS )
            int alt6=2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0==NUMERO) ) {
                alt6=1;
            }
            else if ( (LA6_0==PARENTESIS) ) {
                alt6=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 6, 0, input);

                throw nvae;

            }
            switch (alt6) {
                case 1 :
                    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:28:12: NUMERO
                    {
                    root_0 = (Object)adaptor.nil();


                    NUMERO12=(Token)match(input,NUMERO,FOLLOW_NUMERO_in_exp_base177); 
                    NUMERO12_tree = 
                    (Object)adaptor.create(NUMERO12)
                    ;
                    adaptor.addChild(root_0, NUMERO12_tree);


                    }
                    break;
                case 2 :
                    // C:\\Users\\Javier\\workspace_pl\\practica12\\src\\com\\pl\\ExpParser.g:30:11: PARENTESIS expresion PARENTESIS
                    {
                    root_0 = (Object)adaptor.nil();


                    PARENTESIS13=(Token)match(input,PARENTESIS,FOLLOW_PARENTESIS_in_exp_base203); 
                    PARENTESIS13_tree = 
                    (Object)adaptor.create(PARENTESIS13)
                    ;
                    adaptor.addChild(root_0, PARENTESIS13_tree);


                    pushFollow(FOLLOW_expresion_in_exp_base205);
                    expresion14=expresion();

                    state._fsp--;

                    adaptor.addChild(root_0, expresion14.getTree());

                    PARENTESIS15=(Token)match(input,PARENTESIS,FOLLOW_PARENTESIS_in_exp_base207); 
                    PARENTESIS15_tree = 
                    (Object)adaptor.create(PARENTESIS15)
                    ;
                    adaptor.addChild(root_0, PARENTESIS15_tree);


                    }
                    break;

            }
            retval.stop = input.LT(-1);


            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "exp_base"

    // Delegated rules


 

    public static final BitSet FOLLOW_expresion_in_instrucciones62 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_SEPARADOR_in_instrucciones64 = new BitSet(new long[]{0x0000000000008100L});
    public static final BitSet FOLLOW_EOF_in_instrucciones68 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_exp_mult_in_expresion134 = new BitSet(new long[]{0x0000000000002802L});
    public static final BitSet FOLLOW_SUMA_in_expresion138 = new BitSet(new long[]{0x0000000000008100L});
    public static final BitSet FOLLOW_RESTA_in_expresion141 = new BitSet(new long[]{0x0000000000008100L});
    public static final BitSet FOLLOW_exp_mult_in_expresion145 = new BitSet(new long[]{0x0000000000002802L});
    public static final BitSet FOLLOW_exp_base_in_exp_mult155 = new BitSet(new long[]{0x00000000000000C2L});
    public static final BitSet FOLLOW_MULT_in_exp_mult159 = new BitSet(new long[]{0x0000000000008100L});
    public static final BitSet FOLLOW_DIV_in_exp_mult162 = new BitSet(new long[]{0x0000000000008100L});
    public static final BitSet FOLLOW_exp_base_in_exp_mult166 = new BitSet(new long[]{0x00000000000000C2L});
    public static final BitSet FOLLOW_NUMERO_in_exp_base177 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_PARENTESIS_in_exp_base203 = new BitSet(new long[]{0x0000000000008100L});
    public static final BitSet FOLLOW_expresion_in_exp_base205 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_PARENTESIS_in_exp_base207 = new BitSet(new long[]{0x0000000000000002L});

}